package com.applet.mallappletbackstage.service.impl;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.read.builder.ExcelReaderBuilder;
import com.alibaba.excel.read.metadata.ReadSheet;
import com.applet.mallappletbackstage.entity.ReleaseWork;
import com.applet.mallappletbackstage.entity.vo.ExcelWork;
import com.applet.mallappletbackstage.mapper.ReleaseWorkMapper;
import com.applet.mallappletbackstage.service.ReleaseWorkService;
import com.applet.mallappletbackstage.utils.EasyReadListener;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author ${author}
 * @since 2020-07-31
 */
@Service
public class ReleaseWorkServiceImpl extends ServiceImpl<ReleaseWorkMapper, ReleaseWork> implements ReleaseWorkService {

    @Autowired
    ReleaseWorkMapper releaseWorkMapper;

    @Override
    public boolean uploadExcel(MultipartFile multipartFile) throws IOException {
        EasyExcel.read(multipartFile.getInputStream(), ExcelWork.class, new EasyReadListener(releaseWorkMapper)).sheet().doRead();
        return true;
    }
}
